package com.fw.web.controller.system;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.fw.annotation.Log;
import com.fw.core.controller.BaseController;
import com.fw.core.domain.AjaxResult;
import com.fw.enums.BusinessType;
import com.fw.system.admin.domain.TbGunsUser;
import com.fw.system.admin.service.ITbGunsUserService;
import com.fw.utils.poi.ExcelUtil;
import com.fw.core.page.TableDataInfo;

/**
 * 个人装备背包Controller
 * 
 * @author xxx
 * @date 2021-12-03
 */
@RestController
@RequestMapping("/admin/guns_user")
public class TbGunsUserController extends BaseController
{
    @Autowired
    private ITbGunsUserService tbGunsUserService;

    /**
     * 查询个人装备背包列表
     */
    @PreAuthorize("@ss.hasPermi('admin:guns_user:list')")
    @GetMapping("/list")
    public TableDataInfo list(TbGunsUser tbGunsUser)
    {
        startPage();
        List<TbGunsUser> list = tbGunsUserService.selectTbGunsUserList(tbGunsUser);
        return getDataTable(list);
    }

    /**
     * 导出个人装备背包列表
     */
    @PreAuthorize("@ss.hasPermi('admin:guns_user:export')")
    @Log(title = "个人装备背包", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(TbGunsUser tbGunsUser)
    {
        List<TbGunsUser> list = tbGunsUserService.selectTbGunsUserList(tbGunsUser);
        ExcelUtil<TbGunsUser> util = new ExcelUtil<TbGunsUser>(TbGunsUser.class);
        return util.exportExcel(list, "guns_user");
    }

    /**
     * 获取个人装备背包详细信息
     */
    @PreAuthorize("@ss.hasPermi('admin:guns_user:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return AjaxResult.success(tbGunsUserService.selectTbGunsUserById(id));
    }

    /**
     * 新增个人装备背包
     */
    @PreAuthorize("@ss.hasPermi('admin:guns_user:add')")
    @Log(title = "个人装备背包", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TbGunsUser tbGunsUser)
    {
        return toAjax(tbGunsUserService.insertTbGunsUser(tbGunsUser));
    }

    /**
     * 修改个人装备背包
     */
    @PreAuthorize("@ss.hasPermi('admin:guns_user:edit')")
    @Log(title = "个人装备背包", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TbGunsUser tbGunsUser)
    {
        return toAjax(tbGunsUserService.updateTbGunsUser(tbGunsUser));
    }

    /**
     * 删除个人装备背包
     */
    @PreAuthorize("@ss.hasPermi('admin:guns_user:remove')")
    @Log(title = "个人装备背包", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(tbGunsUserService.deleteTbGunsUserByIds(ids));
    }
}
